int* preorder(struct Node* root, int* returnSize) {
    
    *returnSize = 0;
    int* numArray = 0, numSize = 0, top = 0;
	struct Node** stack = (struct Node**)malloc(sizeof(struct Node*) * 1024);
	struct Node* temp = 0;

	stack[top++] = root;
	while(top)
	{
		temp = stack[--top];
        if(!temp) break;
		if (*returnSize >= numSize) numArray = numArray ? (int*)realloc(numArray, sizeof(int)*(numSize*=2)) : (int*)malloc(sizeof(int)*(numSize=1024));
		numArray[(*returnSize)++] = temp->val;
		for (int i=temp->numChildren-1; i>=0; i--) stack[top++] = temp->children[i];
	}
    return numArray;
}